package ru.ksu.ktk.diploma.sdi.bean;

import java.util.ArrayList;
import java.util.List;

import ru.ksu.ktk.diploma.sdi.model.DescriptionFile;
import ru.ksu.ktk.diploma.sdi.search.Search;

/**
 * User: coldflame, RGareev
 */
public class SearchBean{
	
    private String text;
    private List<DescriptionFile> result;
    private Search searchService;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String search() {
    	//TODO: move searchForUrls into controller
    	List<String> urls = searchService.searchForUrls(getText());
    	result = new ArrayList<DescriptionFile>(urls.size());
    	for(String curUrl : urls)
    		result.add(new DescriptionFile(curUrl));
        return "viewResults";
    }

	/**
	 * @return the result
	 */
	public List<DescriptionFile> getResult() {
		return result;
	}

	/**
	 * @param searchService the searchService to set
	 */
	public void setSearchService(Search searchService) {
		this.searchService = searchService;
	}
	
}